﻿@using Kaiser.Cubic.Models
@using Kaiser.Cubic.Service
 
@{
     var actionName = ViewContext.RouteData.Values["action"].ToString();
    actionName = actionName ?? "Home";
    var menu = new Menu()
        {
            Code = actionName
        };

    var service = new CubicServiceClient();
    var categoryList=service.GetProductCateogrys("1");

    var aboutCubicCategoryList = service.GetNewsCategorysByParentCode("AboutCubic_English")??new NewsCategory[]{new NewsCategory()};
    
}
 
 <div class="link_2_a">
   <a href="@Url.Action("Index","Home")" id="la_1" title="Home" @if (menu.Code.Equals("Index",StringComparison.OrdinalIgnoreCase))
                                                                 {
                                                                     @:class="hover"
                                                                 }></a><span><img src="/images/index_20.png" /></span>
     <a   id="la_2" style="cursor: pointer" title="Products" @if (menu.Code.Equals("ProductList", StringComparison.OrdinalIgnoreCase))
                                                                               {
                                                                                   @:class="hover"
                                                                               }></a>
        <div class="kuang" style="display: none">
                                    <ul>
                                        @foreach (var item in categoryList)
                                        {
                                              <li><a href="@Url.Action("ProductList", "Product")?categoryId=@item.Id">@item.CategoryName</a></li>
                                        }
                          
                                
                                    </ul>
                                </div><span><img src="/images/index_20.png" /></span>
     <a  id="la_3" title="About Cubic" @if (menu.Code.Equals("About", StringComparison.OrdinalIgnoreCase))
                                                                         {
                                                                             @:class="hover"
                                                                         }></a>
       <div class="kuang" style="display: none; left: 160px; width: 120px;">
           <ul>
               @if (aboutCubicCategoryList != null && aboutCubicCategoryList.Any())
               {
                   foreach (var item in aboutCubicCategoryList.FirstOrDefault().children)
                   {
                       <li><a href="@if (!string.IsNullOrWhiteSpace(item.CategoryUrl))
                                    {
                                        @:@item.CategoryUrl
                                    }
                                    else
                                    {
                                        @:@Url.Action("NewsList", "News", new {ctid = @item.Id})
                                    }">@item.CategoryName</a></li>
                   }
               } 
           </ul>
                                </div>
     <span><img src="/images/index_20.png" /></span>
    <a href="/china/Home/Video.html" id="la_4" title="Video" @if (menu.Code.Equals("Video", StringComparison.OrdinalIgnoreCase))
                                                                 {
                                                                     @:class="hover"
                                                                 }></a><span><img src="/images/index_20.png" /></span>
    <a href="@Url.Action("Contact","Home")" id="la_5" title="Contact Us" @if (menu.Code.Equals("Contact", StringComparison.OrdinalIgnoreCase))
                                                                 {
                                                                     @:class="hover"
                                                                 }></a><span><img src="/images/index_20.png" /></span>
                            </div><script>
    $(function() {
        $(".link_2_a  #la_3").hover(
            function() {
                $(".kuang").hide();
                $(this).next("div").show().hover(null, function() {
                    $(this).hide();
                });
            }, function() {
                //$(this).next("div").hide();
            }
        );

        $("#la_2").click(function () {
          //  alert($(this).next("div").find("a").first().attr('href'))
            location.href = $(this).next("div").find("a").first().attr('href');
        });
        
        $("#la_3").click(function () {
            //  alert($(this).next("div").find("a").first().attr('href'))
            location.href = $(this).next("div").find("a").first().attr('href');
        });

    })
</script>